﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Utils.Physics2D.Objects;
using Microsoft.Xna.Framework;

namespace Utils.Physics2D.Collision
{
    public abstract class CollisionHandler
    {
        protected PhysicsObject owner;

        public enum DISPLACE
        {
            NONE,
            SELF,
            OTHER,
            BOTH
        }

        protected CollisionHandler(PhysicsObject owner)
        {
            this.owner = owner;
        }

        public abstract bool CheckCollision(PhysicsObject obj, DISPLACE displacement);

        protected void PushByDir(PhysicsObject obj, DISPLACE displacement, Vector2 pushDir)
        {
            if (displacement == DISPLACE.OTHER)
            {
                obj.Pos += pushDir;
            }
            else if (displacement == DISPLACE.SELF)
            {
                owner.Pos -= pushDir;
            }
            else if (displacement == DISPLACE.BOTH)
            {
                obj.Pos += pushDir * 0.5f;

                owner.Pos -= pushDir * 0.5f;
            }
        }
    }
}
